(SST) ShlWAPI.pas Version 1.08

Developer Reference
(SST)ShlWAPI StrToInt64Ex Function
Converts a literal string representation of the integer part of a signed or unsigned, decimal or hexadecimal number into a signed, 64 bit integer value.
Scope
Global (i.e. this function can be called/accessed from code in any unit that includes/uses (SST)ShlWAPI.pas).
Syntax
function StrToInt64Ex(pszString : LPCSTR; dwFlags : STIF_FLAGS; pllRet : PLargeInteger) : BOOL;
Parameters
pszString [in] A pointer to a zero-terminated string, representing a numerical value in decimal or hexadecimal notation.
dwFlags [in] A unsigned, 32-bit, integer value that is a bit mask, that determines which numerical notations will be recognized and converted.
If this value is set to STIF_DEFAULT (= $00000000) the function will only convert texts that represent numerical values in decimal notation. If this value is set to STIF_SUPPORT_HEX (= $00000001) the function will convert strings that represent numerical values in either decimal or hexadecimal notation.
pllRet [out] The address of, or pointer to, a variable of type TLargeInteger. If the function succeeds, the function sets this variable to the value it interpreted the input string as representing.
Return Values
Returns TRUE if the conversion succeeded, FALSE (= 0) if not.
Remarks
This function is exported by name as of ShlwAPI.dll version 6.0 under Windows 2000 and, possibly, earlier Windows versions (with IE 5 or 6), but is documented as being supported as of ShlWAPI.dll version 5.0 under all, Windows operating systems with IE 4.0. This is an obvious contradiction, which is further compounded, not only, by the questionable declaration of the function prototype ("#if (_WIN32_IE >= _WIN32_IE_IE60)...#endif "), but also, through the lack of a documented ordinal by which the function could be accessed in the event that the documented min. OS versions are correct.
Example
PROCEDURE TForm4.TestShlWAPIStrToInt64Ex(Sender : TObject); VAR numstr : STRING; VAR wcharnumstr : WideString; VAR flags : DWORD; VAR number : TLargeInteger; VAR apiretval : BOOL; VAR newinfoline : STRING; BEGIN numstr := ''; wcharnumstr := ''; flags := 0; //(= STIF_DEFAULT = $00000000;); FillChar(number, SizeOf(number), #0); apiretval := FALSE; newinfoline := ''; numstr := '440000000000'; //flags := STIF_DEFAULT; //= 0, set in var initialization apiretval := StrToInt64Ex(PChar(numstr), flags, @number); newinfoline := 'StrToInt64Ex called with "' + numstr + '" returned : '; IF apiretval = TRUE THEN newinfoline := newinfoline + 'TRUE, ' ELSE newinfoline := newinfoline + 'FALSE, '; newinfoline := newinfoline + IntToStr(number) + ' (0x' + IntToHex(number, 16) + ')'; Memo1.Lines.Add(newinfoline); number := 0; apiretval := FALSE; numstr := '370,100,200,300'; //US/English thousands sepaators //flags := STIF_DEFAULT; //= 0, set in var initialization apiretval := StrToInt64Ex(PChar(numstr), flags, @number); newinfoline := 'StrToInt64Ex called with "' + numstr + '" returned : '; IF apiretval = TRUE THEN newinfoline := newinfoline + 'TRUE, ' ELSE newinfoline := newinfoline + 'FALSE, '; newinfoline := newinfoline + IntToStr(number) + ' (0x' + IntToHex(number, 16) + ')'; Memo1.Lines.Add(newinfoline); number := 0; apiretval := FALSE; numstr := '420.300.200.100'; //European thousands sepaators //flags := STIF_DEFAULT; //= 0, set in var initialization apiretval := StrToInt64Ex(PChar(numstr), flags, @number); newinfoline := 'StrToInt64Ex called with "' + numstr + '" returned : '; IF apiretval = TRUE THEN newinfoline := newinfoline + 'TRUE, ' ELSE newinfoline := newinfoline + 'FALSE, '; newinfoline := newinfoline + IntToStr(number) + ' (0x' + IntToHex(number, 16) + ')'; Memo1.Lines.Add(newinfoline); number := 0; apiretval := FALSE; numstr := ' 120300200100'; //Leading blank/space //flags := STIF_DEFAULT; //= 0, set in var initialization apiretval := StrToInt64Ex(PChar(numstr), flags, @number); newinfoline := 'StrToInt64Ex called with "' + numstr + '" returned : '; IF apiretval = TRUE THEN newinfoline := newinfoline + 'TRUE, ' ELSE newinfoline := newinfoline + 'FALSE, '; newinfoline := newinfoline + IntToStr(number) + ' (0x' + IntToHex(number, 16) + ')'; Memo1.Lines.Add(newinfoline); number := 0; apiretval := FALSE; numstr := '-560000123000'; //Negative number, no hex notation //flags := STIF_DEFAULT; //= 0, set in var initialization apiretval := StrToInt64Ex(PChar(numstr), flags, @number); newinfoline := 'StrToInt64Ex called with "' + numstr + '" returned : '; IF apiretval = TRUE THEN newinfoline := newinfoline + 'TRUE, ' ELSE newinfoline := newinfoline + 'FALSE, '; newinfoline := newinfoline + IntToStr(number) + ' (0x' + IntToHex(number, 16) + ')'; Memo1.Lines.Add(newinfoline); number := 0; apiretval := FALSE; numstr := '-870000321000'; //Negative number, but hex notation permissible flags := 1; //(= STIF_SUPPORT_HEX = $00000001;); apiretval := StrToInt64Ex(PChar(numstr), flags, @number); newinfoline := 'StrToInt64Ex called with "' + numstr + '" returned : '; IF apiretval = TRUE THEN newinfoline := newinfoline + 'TRUE, ' ELSE newinfoline := newinfoline + 'FALSE, '; newinfoline := newinfoline + IntToStr(number) + ' (0x' + IntToHex(number, 16) + ')'; Memo1.Lines.Add(newinfoline); number := 0; apiretval := FALSE; numstr := '0x6FAB0000ECECECEC'; //Valid hex notation flags := 1; //(= STIF_SUPPORT_HEX = $00000001;); apiretval := StrToInt64Ex(PChar(numstr), flags, @number); newinfoline := 'StrToInt64Ex called with "' + numstr + '" returned : '; IF apiretval = TRUE THEN newinfoline := newinfoline + 'TRUE, ' ELSE newinfoline := newinfoline + 'FALSE, '; newinfoline := newinfoline + IntToStr(number) + ' (0x' + IntToHex(number, 16) + ')'; Memo1.Lines.Add(newinfoline); number := 0; apiretval := FALSE; numstr := '-0x9CAB0000EABFDCBA'; //"Negative" hex number flags := 1; //(= STIF_SUPPORT_HEX = $00000001;); apiretval := StrToInt64Ex(PChar(numstr), flags, @number); newinfoline := 'StrToInt64Ex called with "' + numstr + '" returned : '; IF apiretval = TRUE THEN newinfoline := newinfoline + 'TRUE, ' ELSE newinfoline := newinfoline + 'FALSE, '; newinfoline := newinfoline + IntToStr(number) + ' (0x' + IntToHex(number, 16) + ')'; Memo1.Lines.Add(newinfoline); number := 0; apiretval := FALSE; numstr := ' 0X75d300002F4aB9c1A'; //Two /2) leading blanks and upper case X in hex prefix flags := 1; //(= STIF_SUPPORT_HEX = $00000001;); apiretval := StrToInt64Ex(PChar(numstr), flags, @number); newinfoline := 'StrToInt64Ex called with "' + numstr + '" returned : '; IF apiretval = TRUE THEN newinfoline := newinfoline + 'TRUE, ' ELSE newinfoline := newinfoline + 'FALSE, '; newinfoline := newinfoline + IntToStr(number) + ' (0x' + IntToHex(number, 16) + ')'; Memo1.Lines.Add(newinfoline); number := 0; apiretval := FALSE; numstr := ' +12955376'; //Leading space, plus sign, and invalid pointer to Int64 variable flags := STIF_DEFAULT; //(= STIF_DEFAULT = $00000000;); apiretval := StrToInt64Ex(PChar(numstr), flags, NIL); newinfoline := 'StrToInt64Ex called with "' + numstr + '" returned : '; IF apiretval = TRUE THEN newinfoline := newinfoline + 'TRUE, ' ELSE newinfoline := newinfoline + 'FALSE, '; newinfoline := newinfoline + IntToStr(number) + ' (0x' + IntToHex(number, 16) + ')'; Memo1.Lines.Add(newinfoline); number := 0; apiretval := FALSE; //Wide character/Unicode version wcharnumstr := '$F4d7'; //Pascal hex prefix and invalid pointer to Int64 variable numstr := wcharnumstr; flags := 1; //(= STIF_SUPPORT_HEX = $00000001;); apiretval := StrToInt64ExW(PWChar(wcharnumstr), flags, NIL); newinfoline := 'StrToInt64Ex called with "' + numstr + '" returned : '; IF apiretval = TRUE THEN newinfoline := newinfoline + 'TRUE, ' ELSE newinfoline := newinfoline + 'FALSE, '; newinfoline := newinfoline + IntToStr(number) + ' (0x' + IntToHex(number, 16) + ')'; Memo1.Lines.Add(newinfoline); number := 0; apiretval := FALSE; Memo1.Lines.Add(''); END;
StrToInt64Ex called with "440000000000" returned : TRUE, 440000000000 (0x00000066720B3000) StrToInt64Ex called with "370,100,200,300" returned : TRUE, 370 (0x0000000000000172) StrToInt64Ex called with "420.300.200.100" returned : TRUE, 420 (0x00000000000001A4) StrToInt64Ex called with " 120300200100" returned : TRUE, 120300200100 (0x0000001C027360A4) StrToInt64Ex called with "-560000123000" returned : TRUE, -560000123000 (0xFFFFFF7D9D643F88) StrToInt64Ex called with "-870000321000" returned : TRUE, -870000321000 (0xFFFFFF356FF09E18) StrToInt64Ex called with "0x6FAB0000ECECECEC" returned : TRUE, 8046525163202473196 (0x6FAB0000ECECECEC) StrToInt64Ex called with "-0x9CAB0000EABFDCBA" returned : TRUE, -7157627178836828998 (0x9CAB0000EABFDCBA) StrToInt64Ex called with " 0X75d300002F4aB9c1A" returned : TRUE, 6714867057104231450 (0x5D300002F4AB9C1A) StrToInt64Ex called with " +12955376" returned : TRUE, 0 (0x0000000000000000) StrToInt64Ex called with "$F4d7" returned : FALSE, 0 (0x0000000000000000)
Requirements
Unit: Declared and imported in (SST)ShlWAPI.pas
Library: (SST)ShlWAPI.dcu/(SST)ShlWAPI.obj
Unicode: Implemented as ANSI (StrToInt64Ex and StrToInt64ExA) and Unicode (StrToInt64ExW) functions.
Min. ShlWAPI.dll version according to MS SDK doc.: 5.0.
Min. ShlWAPI.dll version based on SST research: 6.0.
Min. OS version(s) according to Microsoft SDK doc.: Windows 2000, Windows NT 4.0 with Internet Explorer 4.0, Windows 98, Windows 95 with Internet Explorer 4.0.
Min. OS version(s) according to SST research.: Windows 2000 with IE 6.0, Windows XP and later.
See Also
StrToInt, StrToIntEx, StrFormatByteSizeA, StrFormatByteSizeW, StrFormatByteSize64A, StrFormatKBSize, StrFromTimeInterval, SHFormatDateTime.
 
Windows APIs: StrToInt64Ex, StrToInt, StrToIntEx, SHFormatDateTime, StrFromTimeInterval, StrFormatByteSize, StrFormatByteSize64A, StrFormatByteSizeEx, StrFormatKBSize.


Document/Contents version 1.00
Page/URI last updated on 07.12.2023
 
Copyright © Stoelzel Software Technologie (SST) 2010 - 2017
Suggestions and comments mail to:
webmaster@stoelzelsoftwaretech.com